package com.hl.unittestlearn;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;

import com.hl.unittestlearn.di.component.DaggerLoginComponent;
import com.hl.unittestlearn.di.module.LoginModule;
import com.hl.unittestlearn.presenter.Presenter;

import javax.inject.Inject;

public class MainActivity extends AppCompatActivity implements IView{

    @Inject
    Presenter presenter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        setContentView(R.layout.activity_main);

        DaggerLoginComponent.builder()
                .loginModule(new LoginModule(this))
                .applicationComponent(MyApplication.getInstance().getApplicationComponent())
                .build()
                .inject(this);
    }


    public void onClick(View view)
    {
        presenter.login("hl","123456");
    }

    @Override
    public void updateView(String result) {
        Log.d("Tag", "updateView: "+ result);
    }

    @Override
    public void loginFailure() {

    }
}
